<script setup lang="ts">
import { reactive } from 'vue';
import { getCurrentInstance } from '@tarojs/taro';
import { reLaunch } from '@tarojs/taro';
import IMG_BLUE_BG from '/@/assets/image/bg/blue-bg.png';
import { APP_EDITION } from '/@/common/constant';

/**
 * @description 当前路由信息
 */
const params = getCurrentInstance().router?.params as {
  /**
   * 前往页面
   */
  toPage?: string;
};

const state = reactive<{
  /**
   * 应用版本
   */
  appEdition: keyof typeof APP_EDITION;
}>({
  appEdition: (process.env.APP_EDITION as keyof typeof APP_EDITION) || 'default',
});
</script>

<template>
  <view class="user-login-now app-page--1">
    <view class="user-login-now__header">
      <view class="user-login-now__header__container">
        <view class="user-login-now__title">欢迎使用，</view>
        <view class="user-login-now__title--sub">
          {{
            {
              default: '航天云筑智慧医院后勤',
              hgy: '慧管用保障平台',
              'jinhua-police-service': '掌上运维管理',
              'can-nang-third-hospital': '航天云筑智慧医院后勤',
            }[state.appEdition]
          }}
        </view>
      </view>
      <image class="user-login-now__header-bg" mode="widthFix" :src="IMG_BLUE_BG" />
    </view>
    <view class="user-login-now__wrapper">
      <nut-button
        class="user-login-now__login-btn"
        type="info"
        block
        @click="
          reLaunch({
            url: `/pages/user/dg-work-login/index?toPage=${params.toPage}`,
          })
        "
      >
        一键登录
      </nut-button>
      <view class="user-login-now__to-other-login-wrapper">
        <view class="user-login-now__to-other-login-wrapper--left">
          <text
            @click="
              reLaunch({
                url: `/pages/user/login-phone/index?toPage=${
                  params.toPage || '/pages/index/index'
                }`,
              })
            "
          >
            短信验证码登录
          </text>
        </view>
        <view class="user-login-now__to-other-login-wrapper--right">
          <text
            @click="
              reLaunch({
                url: `/pages/user/login/index?toPage=${params.toPage || '/pages/index/index'}`,
              })
            "
          >
            用户名密码登录
          </text>
        </view>
      </view>
    </view>
  </view>
</template>

<style lang="scss">
@import './index.scss';
</style>
